package android.slc.mp.ui.page.video;

import android.content.Context;

import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;

import android.slc.ma.MaBaseViewHolder;
import android.slc.mp.R;

import android.slc.mp.SlcMp;
import android.slc.mp.po.i.IVideoItem;
import android.slc.mp.ui.SlcIMpDelegate;
import android.slc.mp.ui.page.SlcMpBaseMpAdapter;
import android.slc.mp.ui.utils.SlcMpTimeUtil;

import java.util.List;

/**
 * Created by slc
 */
public class SlcMpVideoAdapter extends SlcMpBaseMpAdapter<IVideoItem> {

    public SlcMpVideoAdapter(@NonNull Context context, @NonNull List<IVideoItem> date,
                             SlcIMpDelegate mediaPickerDelegate) {
        this(R.layout.slc_mp_item_video, context, date, mediaPickerDelegate);
    }


    public SlcMpVideoAdapter(@LayoutRes int layoutRes, @NonNull Context context, @NonNull List<IVideoItem> date,
                             SlcIMpDelegate mediaPickerDelegate) {
        super(layoutRes, context, date, mediaPickerDelegate);
        initLayoutByType();
    }

    /**
     * 初始化布局类型
     */
    protected void initLayoutByType(){
    }

    @Override
    protected void convert(MaBaseViewHolder helper, final IVideoItem item) {
        helper.setChecked(R.id.checkbox, item.isChecked());
        SlcMp.getInstance().optMpConfig().loadImage(helper.getView(R.id.imageView), item,
                SlcMp.MEDIA_TYPE_VIDEO);
        helper.setText(R.id.tv_title, SlcMpTimeUtil.getTime(SlcMpTimeUtil.getFormat(item.getDuration()), item.getDuration()));
    }
}
